
"""
time : 3018.4.28 
author: hujiangshui
"""
import os,requests

data_dir = os.getcwd()

if not os.path.exists(os.path.join(data_dir,"gray")):
    os.mkdir(os.path.join(data_dir,"gray"))
if not os.path.exists(os.path.join(data_dir,"cut")):
    os.mkdir(os.path.join(data_dir,"cut"))


# os.system("ffmpeg -i SVID_20180429_194641_1.mp4 -r 0.5 out_%06d.png")

for parent,dirnames,filenames in os.walk(data_dir):
    for fileName in filenames:
        if fileName.endswith(".png"):
            print fileName

            # print "cut picture"
            # os.system("convert -crop 25X44+695+1083 "+fileName+" c_"+fileName)

            # print "transfer 90 degree"
            # os.system("convert c_"+fileName+" -rotate c_"+fileName) 

            print "trans to gray picture"
            os.system("convert "+fileName+" -fx '(r+g+b)'  "+os.path.join(data_dir,"gray")+"/"+fileName) #-transpose 90 
             

            print "rotate picture"
            os.system("convert  -rotate '-90' "+os.path.join(data_dir,"gray")+"/"+fileName+" "+os.path.join(data_dir,"gray")+"/"+fileName) #-transpose 90 

            # print "begain find str"
            # proc = os.popen("tesseract  c_"+fileName+ " stdout")
            # proc = os.popen("tesseract "+fileName+ " stdout")

            # print proc.read()




